;
(function() {
    // 1. 全局配置
    axios.defaults.baseURL = 'http://music.it666.com:3666';
    axios.defaults.timeout = 3000;
    axios.defaults.withCredentials = true;

    // 2. 封装get和post请求
    class NJHttp {
        static get(url = "", data = {}) {
            return new Promise(function(resolve, reject) {
                axios.get(url, {
                        params: data
                    })
                    .then(function(response) {
                        resolve(response.data);
                    })
                    .catch(function(error) {
                        reject(error);
                    });
            })
        }
        static post(url = "", data = {}) {
            return new Promise(function(resolve, reject) {
                axios.post(url, {
                        params: data
                    })
                    .then(function(response) {
                        resolve(response.data);
                    })
                    .catch(function(error) {
                        reject(error);
                    });
            })
        }
    }
    // 封装主页api
    class HomeApis {
        static getHomeBanner() {
            return NJHttp.get('/banner', { type: 2 });
        }
        static getHomeRecommend() {
            return NJHttp.get("/personalized", { offset: 0, limit: 6 });
        }
        static getHomeExclusive() {
            return NJHttp.get("/personalized/privatecontent");
        }
        static getHomeAlbum() {
            return NJHttp.get("/top/album", { offset: 0, limit: 6 });
        }
        static getHomeMV() {
            return NJHttp.get("/personalized/mv");
        }
        static getHomeDJ() {
            return NJHttp.get("/personalized/djprogram");
        }
    }

    window.NJHttp = NJHttp;
    window.HomeApis = HomeApis;
})();